import requests

from lxml import etree

domain = "https://hye5z2.umugygaex.com"

headres = {
    "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/123.0.0.0 Safari/537.36"
}

def ReMenBaoLiao(nid):
    html_text = requests.get(domain + f"/archives/{nid}/", headers=headres).text
    etree_text = etree.HTML(html_text)
    html_content = etree_text.xpath('//*[@class="post-content"]')[0]
    result = etree.tostring(html_content, encoding='utf-8').decode()
    print(result)
    # # 定位内容
    # ps = etree_text.xpath('//*[@id="post"]/article/div[3]/p')[1::]  # 内容
    # text_list = []
    # for obj in ps:
    #     ptext = obj.xpath('./text()')
    #     if len(ptext) > 0:
    #         text = "".join(ptext)
    #         text_list.append(text)
    # text_list = "".join(text_list)
    # # 获取图片
    # imgs = etree_text.xpath('//*[@id="post"]/article/div[3]/p/img')
    # img_list = []   # 图片
    # for img in imgs:
    #     ptext = img.xpath('./@src')
    #     if len(ptext) > 0:
    #         img_list.append(ptext[0])



ReMenBaoLiao(57047)